Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce LEDSTRIP timer clock to match CPU clock #4805

Merged
merged 1 commit into from
Jun 9, 2019

Conversation

digitalentity
Copy link
Member

LEDSTRIP timer frequency has value to of 24MHz. On F3 (timer clock 72MHz) this yields prescaler of 3 and everything works normally.

However on F405 (timer clock either 168 or 84 MHz) this may yield a non-integer prescaler of 3.5 on certain timers.
INAV 2.1 used truncation and yielded LEDSTRIP carrier frequency of 933KHz.
INAV 2.2 uses proper rounding and generates LEDSTRIP carrier of 700KHz.

WS2811 expects carrier of 800KHz and based on individual chip tolerances may work (or not work) with different frequency.

This PR lowers timer frequency to 2.4MHz and ensures that integer prescaler is calculated for the following timer clocks: 72 MHz (F3); 84, 168 (F405), 108, 216 (F722).
On F411 operating at 84MHz CPU clock on certain timers this will generate a prescaler of 17.5 (rounded up to 18), but this will yield carrier frequency of 778kHz which should be close enough.

Fixes #4783

@digitalentity digitalentity added this to the 2.2 milestone Jun 8, 2019
@digitalentity digitalentity merged commit c8f0364 into development Jun 9, 2019
@digitalentity digitalentity deleted the de_ledstrip_timer_freq_fix branch June 9, 2019 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant